<script>
import { computed } from 'vue'
export default {
  name: 'SvgIcon',
  props: {
    icon: {
      type: String,
      require: true
    },
    className: String
  },
  setup(props) {
    const iconClass = computed(() => {
      return props.className ? `svg-icon ${props.className}` : 'svg-icon'
    })
    const iconName = computed(() => '#icon-' + props.icon)
    return () => {
      return (
        <svg class={iconClass.value}>
          <use xlink:href={iconName.value}></use>
        </svg>
      )
    }
  }
}
</script>

<style lang="scss" scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>
